# coding=utf-8
import json


import os

if __name__ == '__main__':
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project_1.settings")
    import django
    django.setup()

    from myadmin import models
    from django.db.models import F,Sum,Count,Max,Q
    # 拼接
    from django.db.models.functions import Concat
    from django.db.models import Value
                                    # 根据priceSum分组
    # order = models.Order.objects.values("priceSum").annotate(ids=Sum("priceSum"))
    # order = models.Order.objects.update(address=Concat(F("address"), Value("第一版")))
    # order = models.Order.objects.extra({"aa":"concat('第一把',id)"})   # 拼接   可以重新指定字段
    # for i in order:
    #     print(i.aa)

    # 查询person表，判断每个人的工资是否大于2000   会多一个gt字段大于为1  小于0
    models.Person.objects.all().extra(
        select = {"gt": "salary > 1000"}
    )